package io.dcloud.h527baaa6.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.dcloud.h527baaa6.R;


public class MyLoadingView extends LinearLayout {


    @BindView(R.id.loading_view)
    OverWatchLoadingView mLoadingView;

    public MyLoadingView(Context context) {
        super(context);
        initView();
    }

    public MyLoadingView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    private void initView() {
        inflate(getContext(), R.layout.loading_layout, this);
        ButterKnife.bind(this, this);
        setOrientation(VERTICAL);
    }

    /**
     * 显示隐藏加载页
     */
    public void setShowLoading(boolean isShow) {
        if (isShow){
            setVisibility(VISIBLE);
            mLoadingView.post(new Runnable() {
                @Override
                public void run() {
                    mLoadingView.start();
                }
            });
        }else {
            mLoadingView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    setVisibility(GONE);
                    mLoadingView.end();
                }
            },0);
        }
    }
}
